/*
 * @Author: wan
 * @since: 2020-03-12 17:35:00
 * @lastTime: 2020-03-12 17:35:00
 * @LastEditors: wan
 */
import 'package:color_dart/color_dart.dart';
import 'package:flutter/material.dart';
import 'package:local_coffee/components/c_appbar/custom_appbar.dart';
import 'package:local_coffee/components/c_button/index.dart';
import 'package:local_coffee/components/icon.dart';
import 'package:local_coffee/components/rgba.dart';

class ExampleCButton extends StatefulWidget {
  ExampleCButton({Key key}) : super(key: key);

  _ExampleCButtonState createState() => _ExampleCButtonState();
}

class _ExampleCButtonState extends State<ExampleCButton> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(
        title: 'CButton组件',
        context: context,
      ),
      body: SafeArea(
        child: SingleChildScrollView(
          padding: EdgeInsets.symmetric(vertical: 15, horizontal: 15),
          child: Column(
            children: <Widget>[
              Row(
                children: <Widget>[Text('按钮类型')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(
                        CButton.normal(child: Text('默认按钮'), onPressed: () {})),
                    space(CButton.normal(
                        child: Text('主要按钮'),
                        type: 'primary',
                        onPressed: () {})),
                    space(CButton.normal(
                        child: Text('信息按钮'), type: 'info', onPressed: () {}))
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(CButton.normal(
                        child: Text('危险按钮'), type: 'danger', onPressed: () {})),
                    space(CButton.normal(
                        child: Text('警告按钮'), type: 'warning', onPressed: () {}))
                  ],
                ),
              ),
              Row(
                children: <Widget>[Text('禁用状态')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(CButton.normal(child: Text('主要按钮'), type: 'primary')),
                    space(CButton.normal(child: Text('警告按钮'), type: 'warning'))
                  ],
                ),
              ),
              Row(
                children: <Widget>[Text('边框按钮')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(CButton.normal(
                        child: Text('主要按钮'),
                        type: 'primary',
                        plain: true,
                        onPressed: () {})),
                    space(CButton.normal(
                        child: Text('警告按钮'),
                        type: 'warning',
                        plain: true,
                        onPressed: () {}))
                  ],
                ),
              ),
              Row(
                children: <Widget>[Text('icon按钮')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(CButton.icon(
                        width: 44,
                        icon: icon0xe606(),
                        type: 'primary',
                        onPressed: () {})),
                    space(CButton.icon(
                        width: 44,
                        icon: icon0xe606(),
                        type: 'primary',
                        plain: true,
                        onPressed: () {})),
                    space(CButton.icon(
                        textChild: Text('按钮'),
                        icon: icon0xe606(),
                        type: 'primary',
                        plain: true,
                        onPressed: () {}))
                  ],
                ),
              ),
              Row(
                children: <Widget>[Text('圆角按钮')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(children: <Widget>[
                  space(CButton.icon(
                      borderRadius: BorderRadius.circular(40),
                      width: 44,
                      icon: icon0xe606(),
                      type: 'primary',
                      onPressed: () {})),
                  space(CButton.icon(
                      plain: true,
                      borderRadius: BorderRadius.circular(40),
                      width: 44,
                      icon: icon0xe606(),
                      type: 'primary',
                      onPressed: () {})),
                  space(
                    CButton.normal(
                        width: 80,
                        height: 30,
                        bgColor: RGBA.rgbaccc0b4,
                        type: 'primary',
                        onPressed: () {},
                        borderRadius: BorderRadius.circular(44),
                        child: Text('冰')),
                  ),
                  space(CButton.normal(
                      width: 80,
                      height: 30,
                      plain: true,
                      borderColor: RGBA.rgbaccc0b4,
                      onPressed: () {},
                      borderRadius: BorderRadius.circular(44),
                      child: Text(
                        '热',
                        style: TextStyle(
                          color: RGBA.rgbaccc0b4,
                        ),
                      )))
                ]),
              ),
              Row(
                children: <Widget>[Text('加载按钮')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(
                      CButton.loading(
                        width: 44,
                        type: 'primary',
                        onPressed: () {},
                      ),
                    ),
                    space(
                      CButton.loading(
                          width: 44,
                          type: 'primary',
                          plain: true,
                          onPressed: () {}),
                    )
                  ],
                ),
              ),
              Row(
                children: <Widget>[Text('自定义按钮')],
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10),
                child: Row(
                  children: <Widget>[
                    space(CButton.icon(
                        width: 82,
                        height: 32,
                        bgColor: RGBA.rgba88afd503,
                        textChild: Text(
                          '收藏口味',
                          style: TextStyle(
                              color: RGBA.rgba88afd5, fontSize: 12),
                        ),
                        icon: icon0xe606(
                            size: 12, color: RGBA.rgba88afd5),
                        type: 'primary',
                        onPressed: () {})),
                    space(CButton.icon(
                        width: 82,
                        height: 32,
                        bgColor: RGBA.rgbaff8102,
                        textChild: Text(
                          '冲2赠1',
                          style: TextStyle(
                              color: RGBA.rgbaffffff1, fontSize: 12),
                        ),
                        icon: icon0xe606(
                            size: 12, color: RGBA.rgbaffffff1),
                        type: 'primary',
                        onPressed: () {})),
                    space(CButton.icon(
                        width: 82,
                        height: 32,
                        borderColor: Colors.green,
                        bgColor: RGBA.rgbaff810201,
                        plain: true,
                        textChild: Text(
                          '冲2赠1',
                          style: TextStyle(color: Colors.blue, fontSize: 12),
                        ),
                        icon:
                            icon0xe606(size: 12, color: RGBA.rgbaff8102),
                        onPressed: () {})),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget space(Widget child) {
    return Container(
      margin: EdgeInsets.only(right: 20),
      child: child,
    );
  }
}
